/**
 * 
 */
package com.hcmu.common;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * @author SEVEN
 *
 */
public class SharePreferencesHelper {
	SharedPreferences sp;
	private Context mContext;
	String prefeName; 
	
	public SharePreferencesHelper(Context context) {
		mContext = context;
	}
	
	public SharePreferencesHelper(Context context, String name, int mod){
		mContext = context;
		sp = mContext.getSharedPreferences(name, mod);
	}
	
	
	
	public void registerPreferences(String name, int mod){
		//SharedPreferences sp = mContext.getSharedPreferences(name, mContext.MODE_PRIVATE);
		sp = mContext.getSharedPreferences(name, mod);
	}
	
	public void setPreferences(String key, String value){
		SharedPreferences.Editor editor = sp.edit();
		editor.putString(key, value);
		editor.commit();
	}
	
	public void setPreferences(String key, int value){
		SharedPreferences.Editor editor = sp.edit();
		editor.putInt(key, value);
		editor.commit();
	}
	
	public void setPreferences(String key, Boolean value){
		SharedPreferences.Editor editor = sp.edit();
		editor.putBoolean(key, value);
		editor.commit();
	}
	
	public void setPreferences(String key, Long value){
		SharedPreferences.Editor editor = sp.edit();
		editor.putLong(key, value);
		editor.commit();
	}
	
	public void setPreferences(String key, Float value){
		SharedPreferences.Editor editor = sp.edit();
		editor.putFloat(key, value);
		editor.commit();
	}
	
	public String getPreferences(String key, String defaulValue){
		return sp.getString(key, defaulValue);
	}
	
	public Boolean getPreferences(String key, Boolean defaulValue){
		return sp.getBoolean(key, defaulValue);
	}
	
	public int getPreferences(String key, int defaulValue){
		return sp.getInt(key, defaulValue);
	}
	
	public long getPreferences(String key, long defaulValue){
		return sp.getLong(key, defaulValue);
	}
	
	public float getPreferences(String key, float defaulValue){
		return sp.getFloat(key, defaulValue);
	}
}
